#!/anaconda3/envs/FEALPy/bin python3.8
# -*- coding: utf-8 -*-
# File: data_presto.py
# Author: Bryan SHEN
# E-mail: m18801919240_3@163.com
# Site: Shanghai, China
# Time: 2025/4/11 15:43
# File-Desp:

from sqlalchemy.engine import create_engine
import pandas as pd


# 连接 hive 数据库
engine = create_engine('presto://u_algorithm@trino.aihuishou.com:9090/hive/default')


# 获取AHS的全部属性项和属性值
ahs_property_sql = """
    SELECT
        CAST(date(partition_date) + interval '1' day as varchar) AS partition_date,  -- 日期
        product_category_name,  -- 品类
        product_brand_name,     -- 品牌
        product_name,           -- 型号名称
        property_name,          -- 属性项名称
        property_value_name     -- 属性值名称
    FROM 
        rpt.rpt_platform_trade_price_compass_compare_product_property
    WHERE 
        date(partition_date) = current_date + interval + '-1' day
"""

# 获取ZZ的全部属性项和属性值
zz_property_sql = """
    SELECT
        partition_date,  -- 日期
        category_name,  -- 品类
        brand_name, -- 品牌
        product_name,  -- 型号名称
        property_items_name,  -- 属性项名称
        property_value_name  -- 属性值名称
    FROM 
        dim.dim_external_crawl_product_property_value
    where 
        date(partition_date) = current_date
        and platform_name = 'ZZ'
        and disabled = 0 -- 0表示生效的
"""


# 获取 "当天实时" AHS的全部属性项和属性值
ahs_property = pd.read_sql(ahs_property_sql, engine)

# 获取 "当天实时" ZZ的全部属性项和属性值
zz_property = pd.read_sql(zz_property_sql, engine)



